/**
 * BlueprintServiceImpl.java
 */
package org.yate.oa.service.imp;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yate.oa.dao.IBaseMapperDao;
import org.yate.oa.dao.mapper.BlueprintMapper;
import org.yate.oa.model.Blueprint;
import org.yate.oa.model.FtpContent;
import org.yate.oa.service.BlueprintService;
import org.yate.oa.service.FtpContentService;
import org.yate.oa.utils.Pagination;

/**
 * @author Yate
 * @date Feb 20, 2015
 * @description TODO
 * @version 1.0
 */
@Service
public class BlueprintServiceImpl extends BaseService<Blueprint, Long>
		implements BlueprintService {

	@Resource
	private BlueprintMapper mapper;

	@Resource
	private FtpContentService ftpService;

	@Override
	public Pagination<Blueprint> getEntities(int page, int rows, Blueprint e,
			String orderField, String orderMode) {
		Pagination<Blueprint> p = super.getEntities(page, rows, e, orderField,
				orderMode);
		FtpContent ftmp;
		for (Blueprint tmp : p.getRows()) {
			if (tmp.getFtpId() != null) {
				ftmp = ftpService.getEntity(tmp.getFtpId());
				if (ftmp != null) {
					tmp.setFtp(ftmp);
				}
			}
			ftmp = null;
		}
		return p;
	}

	@Override
	public Blueprint getEntity(Long id) {
		return super.getEntity(id);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.yate.oa.service.imp.BaseService#getMapperDao()
	 */
	@Override
	protected IBaseMapperDao<Blueprint, Long> getMapperDao() {
		return mapper;
	}

}
